/**
 * Copyright 2023 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <string>
#include "plugin/device/ascend/kernel/bisheng/bisheng_kernel_metadata.h"
#include "include/common/utils/anfalgo.h"
#include "kernel/oplib/oplib.h"
#include "kernel/framework_utils.h"

namespace mindspore {
namespace kernel {
void BiShengMetadataInfo(const CNodePtr &kernel_node, std::vector<KernelBuildInfoPtr> *const kernel_info_list) {
  MS_LOG(INFO) << "Setting BiShengMetadataInfo.";
  MS_EXCEPTION_IF_NULL(kernel_node);
  MS_EXCEPTION_IF_NULL(kernel_info_list);

  std::string op_name = common::AnfAlgo::GetCNodeName(kernel_node);
  auto op_info_ptr = mindspore::kernel::OpLib::FindOp(op_name, OpImplyType::kImplyBISHENG);
  if (op_info_ptr == nullptr) {
    MS_LOG(DEBUG) << "BiSheng does not have op [" << op_name << "].";
    return;
  }
  if (!ParseMetadata(kernel_node, op_info_ptr, BISHENG, kernel_info_list)) {
    MS_LOG(WARNING) << "BiSheng parsed metadata op [" << op_name << "] failed.";
    return;
  }
}
}  // namespace kernel
}  // namespace mindspore
